{extend name="public:base" /}
{block name="action"}
<a type="button" class="btn btn-w-m btn-primary"
   href="{:url('create')}"> <i class="fa fa-user-plus"></i> 添加
</a>
<a type="button" class="btn btn-w-m btn-primary"
   href="{:url('dc')}">  导出
</a>
<button  id="cc" class="btn btn-primary btn-w-m"><i class="fa fa-plus"></i> 批量导入</button>
<a href="{:url('dc28')}" class="btn btn-primary btn-w-m"> 导入模板</a>
{/block}
{block name="content"}
<div class="wrapper wrapper-content animated fadeInRight" xmlns="http://www.w3.org/1999/html">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox ">
                <div class="ibox-title">
                    <form method="get">
                        <div class="row">
                            <div class="col-sm-3">
                                <input placeholder="账号" value="{$params['query']}" name="query" type="text"
                                       class="form-control form-control-sm">
                            </div>
                            <div class="col-sm-2">
                                <div class="input-group">
                                    <select class="form-control form-control-sm" name="status">
                                        <option value="" {eq name="params[status]" value="" }selected{/eq}>全部</option>
                                        <option value="3" {eq name="params[status]" value="3" }selected{/eq}>禁用</option>
                                        <option value="1" {eq name="params[status]" value="1" }selected{/eq}>正常</option>
                                        <option value="2" {eq name="params[status]" value="2" }selected{/eq}>锁定</option>
                                    </select>
                                    <span class="input-group-append">
                                    <button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-search"></i>搜索! </button>
                                </span>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>

                <div class="ibox-content">
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th>UID</th>
                                <th>账号</th>
                                <th>昵称</th>
                                <th>手机号码</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {notempty name="list"}
                            {volist name="list" id="vo"}
                            <tr>
                                <td>{$vo.id}</td>
                                <td>{$vo.account}</td>
                                <td>{$vo.username}</td>
                                <td>{$vo.mobile}</td>
                                <td>{$vo.status_name}</td>
                                <td class="project-actions">
                                    <a href="{:url('edit')}?id={$vo['id']}" class="btn btn-warning btn-sm"><i
                                            class="fa fa-edit"></i> 编辑 </a>
                                    <a href="{:url('delete',[],'json')}?id={$vo['id']}"
                                       class="btn btn-danger btn-sm ajax-del"><i class="fa fa-trash-o"></i> 删除 </a>
                                    <a href="{:url('resetPassword',[],'json')}?id= {$vo['id']}"
                                       data-method="put"
                                       data-title="确认重置密码操作吗？"
                                       class="btn btn-primary btn-sm ajax-modal-dialog"><i class="fa fa-steam"></i> 重置密码
                                    </a>
                                </td>
                            </tr>
                            {/volist}
                            {/notempty}
                            </tbody>
                        </table>
                        {if $list}
                        {$list->render()}
                        {/if}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<script type="text/javascript">
$("body").on('click','#cc',function(){
    // alert('123');
    var thisObj = $(this);
    var inputFile = document.createElement("input");
    inputFile.type = "file";
    inputFile.name = "file[]";
    inputFile.multiple = "multiple";
    inputFile.accept = "xls";
    inputFile.click();
    $(inputFile).change(function(){
        var files = inputFile.files;
        for(var i=0;i<files.length;i++){
            uploadImg(files[i],thisObj);
        }
    });
});
function uploadImg(file,thisObj){
    var formData = new FormData();
    formData.append('image', file);
    $.ajax({
        url: "{:url('User/import')}",
        type: "post",
        data: formData,
        dataType:"json",
        contentType: false,
        processData: false,
        mimeType: "multipart/form-data",
        success: function (data) {
            alert(data.msg);
            var url = "{:url('User/index')}";
            location.href=url;
        },
    });
}
</script>
{/block}